//
//  Controller.m -- SplitViewExample controller
//
//  Written by Dwight Everhart
//  Copyright (c) 1996 by Dwight D. Everhart.  All rights reserved.
//  Version 1.1; February 5, 1996
//
//      This notice may not be removed from this source code.
//
//  This object is included in the MiscKit by permission from the author
//  and its use is governed by the MiscKit license, found in the file
//  "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//  for a list of all applicable permissions and restrictions.
//

#import "Controller.h"
#import <misckit/MiscSplitView.h>



@implementation Controller



- awakeFromNib
{
   Window *window = [vertSplitView window];

   [window setFrameAutosaveName: "SplitWindow"];

   [vertSplitView setHorizontal: NO];
   [vertSplitView addSubview: upperHorizSplitView];
   [vertSplitView addSubview: lowerHorizSplitView];
   [vertSplitView setDividersAutosaveName: "Vertical"];

   [upperHorizSplitView setHorizontal: YES];
   [upperHorizSplitView addSubview: topLeftView];
   [upperHorizSplitView addSubview: topRightView];
   [upperHorizSplitView setDividersAutosaveName: "UpperHorizontal"];

   [lowerHorizSplitView setHorizontal: YES];
   [lowerHorizSplitView addSubview: bottomLeftView];
   [lowerHorizSplitView addSubview: bottomRightView];
   [lowerHorizSplitView setDividersAutosaveName: "LowerHorizontal"];

   [vertSplitView display];
   [window makeKeyAndOrderFront: self];
   return self;
}



- splitView: sender getMinY: (NXCoord *) minY maxY: (NXCoord *) maxY
  ofSubviewAt: (int) offset
{
   /* Keep the upper view from shrinking below 100 pixels of height. */
   *minY  = 70.0;

   /* Do the same for the lower view. */
   *maxY -= 70.0;

   if (*maxY < *minY) *maxY = *minY;
   return self;
}

- splitView: sender getMinX: (NXCoord *) minX maxX: (NXCoord *) maxX
  ofSubviewAt: (int) offset
{
   if (sender == upperHorizSplitView) {
      *minX  = 110.0;
      *maxX -= 110.0;
   } else {
      *minX  = 120.0;
      *maxX -= 150.0;
   }

   if (*maxX < *minX) *maxX = *minX;
   return self;
}



@end

